home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / hypercrd / hc2_x / tcprogud.sit / TC Prog Guide / card_48179.txt < prev    next >
Text File  |  1991-02-27  |  1KB  |  27 lines

  1. -- card: 48179 from stack: in
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 4755
  5. -- name: 
  6.  
  7.  
  8. -- part contents for background part 6
  9. ----- text -----
  10. 6.1  if-else
  11.  
  12. -- part contents for background part 4
  13. ----- text -----
  14. Statements are executed conditionally using C's 'if' statement.  Its syntax is simply:
  15.  
  16.     if (expression)
  17.         statement1
  18.     else
  19.         statement2
  20.  
  21. where the 'else' clause is optional.  If the expression is non-zero (true) then statement1 is executed, else statement2 (if present) is executed.   The statements may be simple expression statements or compound statements.  For clarity it is important to indent the statements (typically one tab stop or 4 characters).
  22.  
  23. Since C is permissive about the use of "white space" (spaces, tabs, new-line characters), there are several popular placements for the opening and closing braces of compound statements.  Some programmers place the opening brace at the end of the line containing the 'if' and 'else' statements, while others prefer to indent both the opening and closing braces by the same amount as in the example below.
  24.  
  25. -- part contents for background part 7
  26. ----- text -----
  27. 156